package demo4;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Game {
    public static final String[]  decor = {"♥","♠","♣","♦"};

        //获得牌
        public List<Poker> buyPoker() {

        List<Poker> pokers = new ArrayList<>();

        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                Poker poker = new Poker(decor[i],j);
                pokers.add(poker);
            }
        }
        return pokers;
        }

        //打乱牌
        public void disturbancePoker(List<Poker> pokers) {

            for (int i = pokers.size() - 1; i > 0 ; i--) {
                Random random = new Random();
                int j = random.nextInt(i);
                swap(i,j,pokers);
            }
        }

        //转换牌
        public void swap(int i, int j, List<Poker> pokers) {
            Poker temp = pokers.get(i);
            pokers.set(i,pokers.get(j));
            pokers.set(j,temp);
        }

        //揭牌
        public List<List<Poker>> uncoveringPoker(List<Poker> pokers) {
            List<List<Poker>> hand = new ArrayList<>();
            List<Poker> hand1 = new ArrayList<>();
            List<Poker> hand2 = new ArrayList<>();
            List<Poker> hand3 = new ArrayList<>();
            hand.add(hand1);
            hand.add(hand2);
            hand.add(hand3);

            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 3; j++) {
                    Poker remove = pokers.remove(i); //每次都删除下标为0的牌  意味着揭牌
                    hand.get(j).add(remove);
                }
            }
            return hand;
        }



}
